<template>
  <div>
    <div class="sy_show ftyg_show" v-if="surveyShow">
    <div class="sy_toptitle ftyg_toptitle">
      <p>
       省政府门户网站欢迎您：
      </p>
    </div>
    <div class="sy_close" @click="surveyClose">
    X
    </div>
    <div class="sy_info ftyg_info">
       <div class="sy_text ftyg_text">
         <ul>
               <li>
             <p>
               四川省人民政府门户网站个人中心目前正在试运行阶段。欢迎您在使用过程中提出宝贵意见和建议。衷心感谢您的热心参与。
              </p>
             <div>
               <a href="javascript:;" @click="yjfkShow">意见反馈</a>
             </div>
           </li>
         </ul>
      </div>
    </div>
  </div>
  
  <div class="yjfkwrap" v-if="surveyMsgShow">
    <div class="yjfkbox">
      <p>意见反馈</p>
      <div><iframe src="https://www.sc.gov.cn/10462/grzxly/grzxly.shtml"></iframe></div>
      <div class="close" @click="yjfkClose">X</div>
    </div>
  </div>
  
    <div class="home-info-wrap">
      <el-row class="height100">
        <el-col class="height100" :span="4">
          <div class="height100">
            <img :src="avatarPath" class="avatar-wrap"/>
            <!-- <button class="geng_btn">更换头像</button>   ellipsis-->
          </div>
        </el-col>
        <el-col class="height100" :span="20">
          <div class="app-tit-word"><img src="../assets/image/grzx.png">我的个人中心<span @click="logout">退出登录</span></div>
          <div class="user-info clearfix">
            <div class="person-info fl height100">
              <div class="person-info-item">姓名：{{ userInfo.name  }}</div>
            <!--
              <div class="person-info-item">
                积分：
                <span class="nobegin bg-color1">未开通</span>
              </div>
              -->
              <!--
              <div class="person-info-item">资料完善度：{{ userInfo.level }}</div>
              -->
            </div>
            
            <div class="person-total-view fl clearfix height100">
              <div class="person-card-wrap wd20 height100 fl">
                <div class="person-card" :class="personCardBg[0].class" @mouseleave="changeBg(0,3)" @mouseover="changeBg(0,4)">
                  <div class="person-card-counts">{{ dingyueTotal }}</div>
                  <div class="person-card-label">订阅</div>
                </div>
            </div>
            <div class="person-card-wrap wd20 height100 fl">
                <div class="person-card" :class="personCardBg[1].class" @mouseleave="changeBg(1,4)" @mouseover="changeBg(1,5)">
                  <div class="person-card-counts">{{ shoucangTotal }}</div>
                  <div class="person-card-label">收藏</div>
                </div>
            </div>
              <div class="person-card-wrap wd20 height100 fl">
                <div class="person-card" :class="personCardBg[2].class" @mouseleave="changeBg(2,1)" @mouseover="changeBg(2,2)">
                  <div class="person-card-counts">{{hudongTotal}}</div>
                  <div class="person-card-label">互动</div>
                </div>
              </div>
              <div class="person-card-wrap wd20 height100 fl">
                <div class="person-card" :class="personCardBg[3].class" @mouseleave="changeBg(3,2)" @mouseover="changeBg(3,3)">
                  <div class="person-card-counts">{{ banshiTotal }}</div>
                  <div class="person-card-label">办事</div>
                </div>
              </div>
              <div class="person-card-wrap wd20 height100 fl">
                <div class="person-card" :class="personCardBg[4].class" @mouseleave="changeBg(4,5)" @mouseover="changeBg(4,1)">
                  <div class="person-card-counts">{{ liulanTotal }}</div>
                  <div class="person-card-label">足迹</div>
                </div>
              </div>
            </div>
          </div>
        </el-col>
      </el-row>
    </div>
  <div class="policySend">
    <div class="policyTitle"><img src="../assets/image/zcsd.gif" width="40">政策送达：</div>
    <marquee onmouseover="this.stop();" onmouseout="this.start();" behavior="scroll" direction="left" scrolldelay="120">
      <a v-for="(item,index) in policySend" :key="index" :href="item.url" target="_blank">{{item.title}}</a>
      
    </marquee>
    <span class="policyMore"><a href="/10462/c103042/stt_list.shtml" target="_blank">更多>></a></span>
  </div>
    <div class="home-content-wrap clearfix">
      <div class="home-content-left fl">

        <div class="home-table-wrap clearfix">
          <div class="home-table-title fl">我的订阅</div>
          <div  @click="enterListPage('mysubscibe')" class="home-table-title more-btn fr">更多>></div>
          <div class="home-table">
            <table class="app-table">
              <thead>
                <th>标题</th>
                <th>日期</th>
                <th>操作</th>
              </thead>
              <tbody v-if="mySubscibeList.length">
                <tr v-for="item in mySubscibeList" :key="item.manuscriptId">
                  <td class="ellipsis" style=" cursor: pointer; width:70%"  @click="openNewPage_lookAndCollect(item)" :title="item.channelName">{{ item.channelName| filterWords  }}</td>
                  <td > {{ item.createTime | formatDayTime}} </td>
                  <td >
                    <div class="can-btn" @click="cancleMysubscibe(item)">取消订阅</div>
                  </td>
                </tr>
              </tbody>
              <tbody v-if="!mySubscibeList.length">
                <tr>
                  <td>暂无数据</td>
                  <td>暂无数据</td>
                  <td>暂无数据</td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>

        <div class="home-table-wrap clearfix">
          <div class="home-table-title fl">我的收藏</div>
          <div @click="enterListPage('mycollect')" class="home-table-title more-btn fr">更多>>
</div>
          <div class="home-table">
            <table class="app-table">
              <thead>
                <th>标题</th>
                <th>日期</th>
                <th>操作</th>
              </thead>
              <tbody v-if="myCollectList.length">
                <tr v-for="item in myCollectList" :key="item.manuscriptId">
                  <td style=" cursor: pointer;width:70%" @click="openNewPage_lookAndCollect(item)" :title="item.title">
                    <div class="ellipsis">
                      {{ item.title | filterWords(26) }}
                    </div>
                  </td>
                  <!--
                  <td :title="item.channelName">
                    <div class="ellipsis">
                       {{ item.channelName | filterWords(4) }}
                    </div>
                   </td>
                  <td :title="item.websiteName">
                    <div class="ellipsis">
                       {{ item.websiteName | filterWords(10) }}</div>
                  </td>
                  -->
                  <td :title="item.publishedTime">{{ item.publishedTime  }}</td>
                  <td><div class="can-btn" @click="cancleCollect(item)">取消收藏</div></td>
                </tr>
              </tbody>
              <tbody v-if="!myCollectList.length">
                <tr>
                  <td>暂无数据</td>
                  <td>暂无数据</td>
                  <td>暂无数据</td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>

        <div class="home-table-wrap home-table-hd clearfix">
          <div class="home-table-title fl">我的互动</div>
          <div @click="enterHudongPage" class="home-table-title more-btn fr">更多>></div>
          <div class="btn-wrap">
            <div v-for="item in tabList" @click="changeTab(item)" :key="item.id" :class="{'act-btn':curTab == item.id}"  class="tab-btn">
              {{ item.name }}
            </div>
          </div>
          <div class="home-table">

            <table v-show="curTab == 1" class="app-table">
              <thead>
                <th>受理编号</th>
                <th>标题</th>
                <th>写信日期</th>
                <th>状态</th>
              </thead>
              <tbody v-if="mailList.length">
                <tr v-for="item in mailList" :key="item.id" @click="enterMailDetail(item)" style="cursor:pointer;">
                  <td>{{ item.serialNumber }}</td>
                  <td class="ellipsis">{{ item.title | filterWords(26)   }}</td>
                  <td>{{ item.createTime }}</td>
                  <td>{{ item.status }}</td>
                </tr>
              </tbody>
              <tbody v-if="!mailList.length">
                <tr>
                  <td>暂无数据</td>
                  <td>暂无数据</td>
                  <td>暂无数据</td>
                  <td>暂无数据</td>
                </tr>
              </tbody>
            </table>

            <table v-show="curTab == 2" class="app-table">
              <thead>
                <th>标题</th>
                <th>截止日期</th>
                <th>征集状态</th>
              </thead>
              <tbody v-if="suggestionsList.length">
                <tr v-for="item in suggestionsList" :key="item.id">
                  <td class="ellipsis" @click="enterSuggestDet(item)" style="cursor:pointer;width:65%" :title="item.title">{{ item.title | filterWords(26)  }}</td>
                  <td>{{ item.endTime }}</td>
                  <td class="clearfix">
                    <!--
                    <div v-if="item.collectType==0"  >已结束</div>
                    <div v-else >进行中</div>
                    -->
                    <div v-if="item.isSurvey==2" >进行中</div>
                    <div v-else >已结束</div>
                  </td>
                </tr>
              </tbody>
              <tbody v-if="!suggestionsList.length">
                <tr>
                  <td>暂无数据</td>
                  <td>暂无数据</td>
                  <td>暂无数据</td>
                </tr>
              </tbody>
            </table>

            <table v-show="curTab == 3" class="app-table">
              <thead>
                <th>标题</th>
                <th>日期</th>
                <th>受理状态</th>
              </thead>
              <tbody v-if="surveyList.length">
                <tr v-for="item in surveyList" :key="item.id">
                   <td style="width:65%" >{{ item.rqsttitle | filterWords(26) }}</td>
                   <td>{{ item.answertime }}</td>
                   <td>{{ item.status }}</td>
                </tr>
              </tbody>
              <tbody v-if="!surveyList.length">
                <tr>
                  <td>暂无数据</td>
                  <td>暂无数据</td>
                  <td>暂无数据</td>
                </tr>
              </tbody>
            </table>

            <table v-show="curTab == 4" class="app-table">
              <thead>
                <th>办事名称</th>
                <th>提交时间</th>
                <th>受理状态</th>
              </thead>
              <tbody v-if="inspectionList.length">
              <tr v-for="item in inspectionList" :key="item.id" @click="enterInspectionDetail(item)" style="cursor:pointer;">
                <td class="ellipsis" style="width:65%" >{{ item.govInfo | filterWords(20)}}</td>
                <td>{{ item.applyTime | formatDate}}</td>
                <td>{{ item.handleStatus | statusHandler }}</td>
              </tr>
              </tbody>
              <tbody v-if="!inspectionList.length">
              <tr>
                <td>暂无数据</td>
                <td>暂无数据</td>
                <td>暂无数据</td>
                
              </tr>
              </tbody>
            </table>
          </div>
        </div>

        <div class="home-table-wrap clearfix">
          <div class="home-table-title fl">我的办事 </div>
          <div @click="enterListPage('mything')" class="home-table-title more-btn fr">更多>></div>
          <div class="home-table">
            <table class="app-table">
              <thead>
                <th>事项名称</th>
                <th>受理部门</th>
                <th>申报时间</th>
                <th>进度</th>
              </thead>
              <tbody v-if="myThing.length">
                <tr v-for="item in myThing" :key="item.code">
                  <td class="ellipsis" style=" cursor: pointer;width:40%" @click="openNewPage(item)" :title="item.eventName">{{ item.eventName | filterWords  }}</td>
                  <td :title="item.deptName">{{ item.deptName | filterWords }}</td>
                  <td :title="item.createTime">{{ item.createTime  }}</td>
                  <td :title="item.manaStatus">{{ item.manaStatus | filterWords }}</td>
                </tr>
              </tbody>
              <tbody v-if="!myThing.length">
                <tr>
                  <td>暂无数据</td>
                  <td>暂无数据</td>
                  <td>暂无数据</td>
                  <td>暂无数据</td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
        
        <!--
        <div class="home-table-wrap clearfix">
          <div class="home-table-title fl">我的浏览</div>
          <div @click="enterListPage('mylook')" class="home-table-title more-btn fr">更多</div>
          <div class="home-table">
            <table class="app-table">
              <thead>
                <th>标题</th>
                <th>栏目</th>
                <th>站点</th>
                <th>日期</th>
              </thead>
              <tbody v-if="myLookList.length">
                <tr v-for="item in myLookList" :key="item.manuscriptId">
                  <td style=" cursor: pointer;" @click="openNewPage_lookAndCollect(item)" :title="item.title">{{ item.title| filterWords  }}</td>
                  <td :title="item.channelName">{{ item.channelName | filterWords(6) }}</td>
                  <td :title="item.websiteName">{{ item.websiteName | filterWords(10) }}</td>
                  <td :title="item.publishedTime">{{ item.publishedTime  }}</td>
                </tr>
              </tbody>
              <tbody v-if="!myLookList.length">
                <tr>
                  <td>暂无数据</td>
                  <td>暂无数据</td>
                  <td>暂无数据</td>
                  <td>暂无数据</td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
        -->
        
      </div>

      <div class="home-content-right fl">
        <div class="right-area">
          <div class="your-look">
            <div class="right-area-tit">我的足迹</div>
            <div v-if="myLookList.length">
              <div class="your-look-list-item" v-for="item in myLookList" :key="item.manuscriptId">
                <div
                  class="your-look-list-title"  @click="openNewPage_lookAndCollect(item)"
                >{{  item.title | filterWords(21) }}</div>
                <!-- <div class="your-look-list-date">日期：{{ item.publishedTime }}</div> -->
              </div>
            </div>

            <div v-else class="your-look-list-item" style="border-bottom:none">
              <div  class="your-look-list-title pf10"> 暂无数据</div>
            </div>

          </div>

          

          <div class="word-cloud">
            <div class="right-area-tit">您的标签云</div>
            <div class="word-cloud-area" ref="tagscloud">
              <ul class="st-classify-rank-list" ref="classifyResRank">
                <li
                  class="st-err-item"
                  :class="[item.colorClass, item.fsClass]"
                  v-for="item in wordCloudList"
                  :key="item.id"
                >{{item.name}}</li>
              </ul>
            </div>
          </div>

          <div class="your-like">
            <div class="right-area-tit">猜您喜欢</div>
            <div v-if="gussesYourList.length">
              <div class="your-like-list-item" v-for="item in gussesYourList" :key="item.manuscriptId">
                <div class="your-like-list-title" @click="openNewPage_like(item)">
                  {{  item.title | filterWords(21) }}
                </div>
                <!-- <div class="your-like-list-date">日期：{{ item.publishedTime }}</div> -->
              </div>
            </div>

            <div v-else class="your-like-list-item" style="border-bottom:none">
              <div  class="your-like-list-title pf10"> 暂无数据</div>
            </div>
          </div>

        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from 'axios';
import { tagsCloud, update } from "@/utils/tagscloud.js";
import {
  getUserInfo,getMailList,getSubscibeData,getCollectData,getUserLikeData,
  getwordCloud,cancleCollectData,hudongData,cancleMysubscibeData,getMyThingData,policyRequest
} from '@/api';

export default {
  data() {
    return {
      userInfo:{
        name:'无',
        level:'L1',
        mobile:'',
        idNo:'',
        userType:'' 
      },
      wordCloudList: [
      ],
      personCardBg:[
        {class:'person-card3',type:'订阅'},
        {class:'person-card4',type:'收藏'},
        {class:'person-card1',type:'互动'},
        {class:'person-card2',type:'办事'},
        {class:'person-card5',type:'足迹'},
        ],
      timer: null,
      avatarPath:"",
      curTab:'2',
      tabList:[
    //    { name:'省长信箱',id:1,routePath:"mail"},
        { name:'意见征集',id:2,routePath:"suggestions"},
        { name:'在线留言',id:3,routePath:"survey"},
        { name:'依申请查询',id:4,routePath:"inspection"}
      ],
      mailList:[], // 信件
      inspectionList:[],//依申请公开 --督查
      suggestionsList:[], // 征集
      surveyList:[], // 调查
      myThing:[], //我的办件
      myCollectList:[], // 我的收藏
      myLookList:[
      ], // 我的浏览
      mySubscibeList:[], //我的订阅
      gussesYourList:[
      ], //猜您喜欢
      hudongTotal:0,
      banshiTotal:0,
      dingyueTotal:0,
      shoucangTotal:0,
      liulanTotal:0,
      userObj:{},
      surveyShow:true,
      surveyMsgShow:false,
      policySend:[]   //政策送达
    };
  },
  computed:{
    getUser(){
      return this.$store.state.user;
    }
  },
  mounted() {
    this.getUserInforMation();
    this.getPolicyList();
  },
  destroyed(){
    if(this.timer){
      clearInterval(this.timer);
      this.timer = null;
    }
  },
  methods: {

    tagsCloud: tagsCloud,
    update: update,
    changeTab(item){
      this.curTab = item.id;
      if(this.curTab == 1){
        this.getMaillListData();  // 信件
      }else if(this.curTab == 2){
        this.getSuggestionsList();  // 征集
      }else if(this.curTab == 3){
        this.getSurveyList();
      }else {
        this.getInspectionListData();
      }
    },
    enterHudongPage(){
      let routePath = ''
      this.tabList.forEach(item=>{
        if(item.id == this.curTab){
          routePath = item.routePath
        }
      })
      this.$router.push({ name:routePath || 'home' });
    },
    enterListPage(routeName){
      document.body.scrollTop = document.documentElement.scrollTop = 0;

      this.$router.push({ name:routeName || 'home' });
    },
    initData(){
      this.initWordCloud();
     // this.getMaillListData();  // 信件
      this.getSuggestionsList(); 
      this.getMyCollectList(); // 收藏
      this.getMyLookList(); // 浏览
      this.getMySubscibeList(); // 订阅
      this.getUserLikeList(); // 您喜欢
      this.getHudongTotal(); // 互动总数
      this.getThingTotal(); // 办件总数
      this.getMyThing() ;//我的办件
    },
    getUserInforMation(){
      let url = '/sys/sysMember/getMember';
      getUserInfo(url).then(res=>{
        if(res.data.code == 200){
          var trueName = res.data.data.realName;
          
          if(trueName.length>6){
            trueName =  "*" + trueName.substring(1,5)+ "...";
          }else{
            trueName =  "*" + trueName.substring(1,trueName.length);
          }
          this.userInfo.name =  trueName;
          this.userInfo.level =  res.data.data.mobile? 'L2':'L1';
          this.userInfo.mobile =  res.data.data.mobile;
          this.userInfo.idNo =  res.data.data.idNo;
          this.userInfo.userType =  res.data.data.userType;
          let defaultPath  = require('../assets/image/no_avatar.jpg');
          this.avatarPath = res.data.data.photo? res.data.data.photo:defaultPath;
          this.userObj = res.data.data;
          this.$store.commit('setUserinfo',{
            id:res.data.data.id,
            name:res.data.data.realName,
            mobile:res.data.data.mobile,
            idNo:res.data.data.idNo,
            userType:res.data.data.userType
          })
          this.initData();
        }
      })
    },
    filterWordLength(txt, length) {
      return txt.length <= length ? txt : txt.substr(0, length) + "...";
    },
    getMaillListData(){ //我的信件
      let url = '/sys/sysMember/getMailList';
      let params = {
        memberId:this.getUser.id,
        pageNum: 1,
        pageSize: 5,
      }
      getMailList(url,params).then(res=>{
        if(res.data.status == 'success'){
          this.mailList = res.data.data.rows || [];
        }else{
          this.mailList = [];
        }
      })
    },
    getInspectionListData(){ //我的依申请公开   -- 督查
      let url = '/sys/sysMember/personSearchList';
      let params = {
        userType:this.getUser.userType,
        pageNum: 1,
        pageSize: 5,
      }

      let userTy = this.getUser.userType;
      if(userTy=='user'){
        let truname = this.getUser.name;
        let mobilestr  = this.getUser.mobile;
        params.trueName = '*'+ truname.substring(1,truname.length);
        params.phoneNumber = mobilestr.substr(0,3) + '****'+ mobilestr.substr(7,4);
      }

      getMailList(url,params).then(res=>{
        if(res.data.Status == 'true'){
          this.inspectionList = res.data.data || [];
        }else{
          this.inspectionList = [];
        }
      })
    },

    getSurveyList(){ //我的调查
      let url = '/sys/sysMember/getmyrqstanswerbycardnum';
      //'/sys/sysMember/getFrontQuestionPaper';   
      let params = {
            userName: this.getUser.name,
            mobile: this.getUser.mobile,
            cardNum: this.getUser.idNo,
            rqstType: 10
      }
      getMailList(url, params).then(res => {
            if (res.data.Status == 'true') {
              if(res.data.data.length > 5){
                 this.surveyList = (res.data.data).slice(0,5)
              } else{
                 this.surveyList = res.data.data || [];
              }       

            } else {
                this.surveyList = [];
                        
            }
      })
    },
    // toSurveyDet(item){
    //   let url = window.location.protocol+ '//'+window.location.host +'/account-center/a/sys/sysMember/toSolicitationDetail?urls=/h5/hd_zxdc_details_pc.html&id='
    //   url = url+item.id;
    //   url = url+'&memberId='+ this.getUser.id;
    //   window.open(url,"_blank")
    // },
    // toSurveyResult(item){
    //   let url = url = window.location.protocol+ '//'+window.location.host +'/account-center/a/sys/sysMember/toSolicitationDetail?urls=/h5/hd_zxdc_result_pc.html&id='
    //   url = url+item.id;
    //   url = url+'&memberId='+ this.getUser.id;
    //   window.open(url,"_blank")
    // },
    openNewPage(item){
      window.open(item.detailsUrl,"_blank");
    },

    openNewPage_like(item){
      window.open(item.url,"_blank");
    },

    getSuggestionsList(){ //我的征集
      let url = '/sys/sysMember/getFrontArticleList';
      let params = {
        phone:  this.getUser.mobile,
        pageNum: 1,
        pageSize: 5
      }
      getMailList(url,params).then(res=>{
        if(res.data.status == 'success'){
          this.suggestionsList = res.data.data.rows || [];
          this.hudongTotal = res.data.data.total;
        }else{
          this.suggestionsList = [];
        }
      })
    },
     
    enterSuggestDet(item){
      /*
       let url = window.location.protocol+ '//'+window.location.host +'/account-center/a/sys/sysMember/toSolicitationDetail?urls=/h5/hd_myzj_input_pc.html&id='
       url = url+item.id;
       url = url+'&memberId='+ this.getUser.id;
       window.open(url,"_blank") */

       let url = 'http://www.sc.gov.cn/10462/c100410/yjzj01.shtml?id=' + item.id;
       window.open(url, "_blank");
    },

    getMyThing(){
      let url = 'sys/sysMember/getMyThingStatusList';
      let params = {
        memberId: this.getUser.id,
        idNumber: this.getUser.idNo, 
        phoneNumber:this.getUser.mobile,
        status: '30',
        pageNum: 1,
        pageSize: 5,
        userType: this.getUser.userType,          //this.getUser.
      }
      getCollectData(url,params).then(res=>{
        if(res.data.Status == 'true'){
          this.myThing = res.data.data || [];
        }else{
          this.myThing = [];
        }
      })
      /*
      let data = {
        "token": "Epoint_WebSerivce_**##0601",
        params:{
          currentpage: 0,
          pagesize: 5,
          status:0,
          applyerpagecode:this.userObj.idNo,
          applyername:this.userObj.realName,
          projectname:'',
          applyertype:this.userObj.userType,
          accountguid:this.userObj.id,
          usertype:this.userObj.userType
        }
      }
      let saveToken = window.localStorage.getItem('token');
      this.$axios.post(
        myThingUrl,
        data,
        { headers:{'Authorization':"Bearer "+ saveToken    } },
      ).then(res=>{
        if(res.data.status.code == 200){
          this.myThing = res.data.custom.projectlist || []
        }else{
          this.myThing = []
        }
      })*/
    },
    getMyCollectList(){//我的收藏
      let url = 'sys/sysMember/qryManuscriptByuserId';
      let params = {
        memberId:this.getUser.id,
        pageNum: 1,
        pageSize: 5,
        type:1,
      }
      getCollectData(url,params).then(res=>{
        if(res.data.Status == 'true'){
          this.myCollectList = res.data.data || [];
          this.shoucangTotal = res.data.pager.totalCount || 0;
        }else{
          this.myCollectList = [];
          this.shoucangTotal =  0;
        }
      })
    },
    getMyLookList(){//我的浏览
      let url = 'sys/sysMember/qryManuscriptByuserId';
      let params = {
        memberId:this.getUser.id,
        pageNum: 1,
        pageSize: 6,
        type:2,
      }
      getCollectData(url,params).then(res=>{
        if(res.data.Status == 'true'){
          this.myLookList = res.data.data || [];
          this.liulanTotal = res.data.pager.totalCount || 0;
        }else{
          this.myLookList =  [];
          this.liulanTotal =  0;
        }
      })
    },
    getMySubscibeList(){ //我的订阅
      let url = '/sys/sysMember/qrySubscriptionChannelByuserId';
      let params = {
        memberId: this.getUser.id,
        pageNum :1,
        pageSize :5
      }
      getSubscibeData(url,params).then(res=>{
        if(res.data.Status == 'true'){
          this.mySubscibeList = res.data.data || [];
          this.dingyueTotal = res.data.pager.totalCount || 0;
        }else{
          this.mySubscibeList = [];
          this.dingyueTotal = 0;
        }
      })
    },
    getUserLikeList(){ //您喜欢
      let url =  '/sys/sysMember/guessUserLikeByuserId';
      let params = {
        memberId: this.getUser.id,
      }
      getUserLikeData(url,params).then(res=>{
        if(res.data.Status == 'true'){
          var arr = res.data.data || [];
          if(arr.length >4){// 超过3个取3个
            arr = arr.slice(0,4)
          }
          this.gussesYourList =  arr;
        }else{
          this.gussesYourList.length = [];
        }
        // console.log(res,'您喜欢')
      })
    },
    cancleCollect(item){
      let url = '/sys/sysMember/updataRecordsByuserId';
      let params = {
        memberId: this.getUser.id,
        type:1,
        manuscriptId :item.manuscriptId
      }
      cancleCollectData(url,params).then(res=>{
        if(res.data.Status == 'true'){
          this.getMyCollectList()
          this.$message({
            type: "success",
            duration: 3000,
            message: "取消成功"
          });
        }else{
          this.$message({
            type: "error",
            duration: 3000,
            message: "操作失败，请重试"
          });
        }
      })
    },
    cancleMysubscibe(item){
      // console.log(item,'item')
      let url = '/sys/sysMember/cancelSubscriptionChannel';
      let params = {
        memberId: this.getUser.id,
        channelId :item.channelId
      }
      cancleMysubscibeData(url,params).then(res=>{
        // console.log(res,'res111')
        if(res.data.Status == 'true'){
          this.getMySubscibeList()
          this.$message({
            type: "success",
            duration: 3000,
            message: "取消成功"
          });
        }else{
          this.$message({
            type: "error",
            duration: 3000,
            message: "操作失败，请重试"
          });
        }
      })
    },
    getHudongTotal(){
      let url = '/sys/sysMember/getWorkNotify';
      let params = {
        memberId: this.getUser.id,
      }
      hudongData(url,params).then(res=>{
        if(res.data.status == 'success'){
          this.hudongTotal= res.data.data.total || 0;
        }
      })
    },
    getThingTotal(){
      let url = '/sys/sysMember/getMyThingCount';
      let params = {
        idNumber: this.getUser.idNo, 
        phoneNumber:this.getUser.mobile,
        userType: this.getUser.userType 
      }
      getMyThingData(url,params).then(res=>{
        if (res.data.Status == 'true') {
           var totalC = res.data.data.status0 +res.data.data.status10 +res.data.data.status30 + res.data.data.status40+res.data.data.status50;
           this.banshiTotal=totalC;
        }
      })
    },
    openNewPage_lookAndCollect(item){
      var a = document.createElement('a');
      a.setAttribute('href', item.url);
      a.setAttribute('target', '_blank');
      a.setAttribute('id', 'lookandcollect');
      if(document.getElementById('lookandcollect')) {
          document.body.removeChild(document.getElementById('lookandcollect'));
      }
      document.body.appendChild(a);
      a.click()
    },
    enterPeople(num){
      this.$router.push( { name:"peopleserve",query:{ type : num } })
    },
    initWordCloud() {
      var url = '/sys/sysMember/getTagCloudByuserId';
      let params = {
        memberId: this.getUser.id,
        number :10
      }
      getwordCloud(url,params).then(res=>{
        // console.log(res,'词云')
        if(res.data.Status == 'true' && res.data.data.length ){
          let arr  = res.data.data || [];
          let newArr =  arr.map((item,index)=>{
            return {
              name:item,
              id:index,
            }
          })
          this.wordCloudList = newArr;
        }else{
          this.wordCloudList =  [
            { name: "暂无标签", id: 0 },
            { name: "暂无标签", id: 1 },
            { name: "暂无标签", id: 2 },
            { name: "暂无标签", id: 3 },
            { name: "暂无标签", id: 4 },
          ];
        }

        for (let item of this.wordCloudList) {
          item.colorClass = "color" + Math.ceil(Math.random() * 6);
          item.fsClass = "fs3";
        }
        if (this.timer) {
          clearInterval(this.timer);
          this.timer = null;
        }
        this.$nextTick(() => {
          this.tagsCloud(this.$refs.tagscloud);
          this.update();
          this.timer = setInterval(this.update, 80);
        });
      })
    },
    changeBg(idx,index){
      this.personCardBg[idx].class = "person-card" + index;
    },
    enterMailDetail(item){
      if(process.env.NODE_ENV === "production"){
        window.open("/usercenter/mailDetail?id=" + item.id, "_blank")
      }else {
        window.open("/mailDetail?id=" + item.id, "_blank")
      }
    },
    logout(){
      window.open("http://www.sc.gov.cn/account-center/a/logout","_self");
      // window.open("http://202.61.88.67:8080/open-platform-exchange/exchange/getResource?resourceCode=ZYZC2019112500000197&applyCode=YYSQ2020072400001024&sysCode=0003&target=https://www.sc.gov.cn/","_self");
    },
    getPolicyList(){
      var url = "/cms-scsrmzf/qryManuscriptByWebsiteId";
      var params = {"pageNum":1,"pageSize":5,"channelId":["0b762951b9044ba2b5a36c08cacac873"]};
      axios.post(url,params).then(res=>{
        var datalist = res.data.results;
        this.policySend = datalist;
      })
    }
    ,
    enterInspectionDetail(item){
     
      if(process.env.NODE_ENV === "production"){
        window.open("/usercenter/inspectionDetail?id=" + item.id, "_blank")
      }else {
        window.open("/inspectionDetail?id=" + item.id, "_blank")
      }
    },
    surveyClose(){
      this.surveyShow = false;
    },
    yjfkShow(){
      this.surveyMsgShow = true;
    },
    yjfkClose(){
      this.surveyMsgShow = false;
    },
    /*
    enterSuggestDet(item) {
      if (item.collectType == "0") {
        if (process.env.NODE_ENV === "production") {
          window.open("/usercenter/suggestionsDetail?id=" + item.id, "_blank")
        } else {
          window.open("/suggestionsDetail?id=" + item.id, "_blank")
        }
      } else {
        window.open(item.outjoin, "_blank")
      }

    },*/

    toSurveyDet(item) {
      if (process.env.NODE_ENV === "production") {
        window.open("/usercenter/surveySubmit?id=" + item.id, "_blank")
      } else {
        window.open("/surveySubmit?id=" + item.id, "_blank")
      }
    },
    toSurveyResult(item) {
      if (process.env.NODE_ENV === "production") {
        window.open("/usercenter/surveyResult?id=" + item.id, "_blank")
      } else {
        window.open("/surveyResult?id=" + item.id, "_blank")
      }

    },
  },

  filters: {
    statusHandler: function (str) {
      if (!str) {
        return "--";
      } else{
        switch(str)
          {
          case 1:
            str = "待处理";
            break;
          case 2:
            str = "处理中";
            break;
          case 3:
            str = "已处理";
            break;
          default:
            str = "已废止";
          }
      }
      return str; 
    }
  }

};
</script>
